<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>CS334: Windows Programming</title></head><body>

<center><h3>
            CS334 - Prog 8: Readers and Writers
</h3></center>

The program has two projects: ReaderWriter and Prog8.

<h3> Project ReaderWriter </h3>
This is a class library project and it <b>MUST</b> the following:

<h5> Two enumeration data types: </h5>
<pre>    Public Enum State
       Wait
       Start
       Finish
    End Enum

    Public Enum ReaderWriterType
        Reader
        Writer
    End Enum
</pre>

<h5> A Delegate </h5>
<pre>    Public Delegate Sub PassMessage(ByVal theID As String, _
                           ByVal theState As State, ByVal Total As Short)
</pre>

<h5> An interface: </h5>
<pre>    Public Interface ReaderWriter
    WriteOnly Property DisplayMsg() As PassMessage
    WriteOnly Property mainForm() As Form
    ReadOnly Property ID() As String
    ReadOnly Property type() As ReaderWriterType

    Sub SpinUp()
    Sub WakeUp()
    End Interface
</pre>

<h5> Classes Reader and Writer </h5>
<pre>    Both classes must implement interface ReaderWriter.
    <b>Both classes can only have private members, including all properties and methods.</b>
    A reader takes 1 to 5 seconds to read, and a writer tales 3 to 5 seconds to write.
    Each writer will generate a number between -10 and 10 to modify the amount.
    Both classes should use a random number generator to produce those numbers.        
</pre>

<h5> A module (or a class) </h5>
<pre>    You must use a queue to inforce the FIFO rule.
    You must use monitor to enforce mutual exclusion.
    The total amount is 100 at the beginning.
</pre>

<h3> Project Prog8 </h3>

This is a Windows Application project with one form.

<ol>
         <li>
         The title of the form is "Readers and Writers - FIFO" followed by your name. 
         The border style is Fixed3D and its size is (650, 400). </li>
         <li>
         The form has a small textbox txtTotal with a label and a large textbox txtLog 
         in the middle. Both textboxes should be readonly and empty at the beginning. </li>
         <li>
         On the right side of the textboxes, there is a listbox, lstWaiting with label 
         "Waiting." On the left side, there is another listbox, lstWorking with label 
         "Working." </li>
         <li>
            There are 3 command buttons at the bottom with captions "New Readers," "New 
            Writers," and "EXIT."</li>
</ol>

<h5> The Functionality </h5>
<ol>
         <li>
            The form has a sub to handle the messages passed from the readers and writers. 
            For each new reader and writer, 
            The pseudocode of the Sub is given as follows:
            <pre>            Case State.Wait
                Add the ID to lstWaiting

            Case State.Start
                Move the Reader/Writer from lstWaiting to lstWorking
                Write a message to txtLog

            Case State.Finish
                Remove the Readre/Writer from lstWorking
                Write a message to txtLog
                Modify txtTotal.Text 
</pre> </li>
<!--            You should use Monitor to control the message writing.-->
            
         <li>
         Clicking on "New Readers" will generate a new object of class Reader and start 
         the reader thread. </li>
         <li>
         Clicking on "New Writers" will generate a new object of class Writer and start 
         the writer thread. </li>
         <li>
            All the readers and writers must follow the FIFO rule. </li>
         <li>
            Clicking on "EXIT" will disable the other two buttons and wait for all working 
            and waiting readers/writers to finish their work. Then a message box will be 
            dispalyed to ask if the user really wants to terminate the program. The program 
            will be terminated if the user chooses Yes. Otherwise, the program will continue to 
            run with the other two buttons enabled.
         </li>
         <li> When waiting for the readers and writers to finish their work, 
              the messages from the readers and writers will be processed promptly
              and displayed in the textboxes on the form. </li>
      </ol>

<h3> Submission </h3>
<ol>
<li> You must do the program in groups, the same groups as for the project. Each group will decide if the group
     should be divided into two subgroups for the program. </li>
<li> You must sign a group sheet by noon, Thursday, May 3. </li>
<li> Use the UserName of one student to name the solution folder. </li>
<li> Drop your solution folder to folder Prog8 of the class DROP folder by 5 PM, Thursday, May 10, 2007. </li>
<li> You must send an email to the instructor by 5 PM, Thursday, May 10, 2007.
     <br> 
     Answer the following three questions in the email (1 is the lowest score and 5 is the highest score):
     <ol>
     <li> What do you think of your partner's programming skill? (1 to 5) </li>
     <li> What do you think of your partner's contribution to the program? (1 to 5) </li>
     <li> Do you want to work with your partner in the future? (1 to 5) </li>
     </ol>
     </li>
<li> You may lose up to two points for incorrect submission, including missing email and incorrect folder name. </li>
<li> You must follow the programming rules, and you may lose up to 2 points on style. </li>
</ol>

</body></html>